API_KEY subjects authenticate technical clients via the
Hostsharing-Api-Key HTTP header instead of a Keycloak OIDC
JWT, e.g. automation programs, completely bypassing Keycloak. Only a
global-admin may create API_KEY subjects. The clear-text API-key is
returned only once, in the response of creating the API_KEY subject;
just its hash gets stored. Like GROUP subjects, API_KEY subjects cannot
have an account. Global API_KEY subjects do not belong to a realm, thus
their name must neither contain a - (the realm-prefix
delimiter) nor a / (the GROUP subject marker).
| name | value |
|---|---|
| subjectUuid | a91c0001-0000-0000-0000-000000000001 |
| subjectName | master.key |
The response contains the generated clear-text API-key (property
apiKey) exactly once; it cannot be retrieved again.
HTTP POST "/api/rbac/subjects" \
-H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
`# {` \
`# "sub" : "uuid<hsh-alex_superuser>"` \
`# }` \
<<EOF
{
"uuid" : "a91c0001-0000-0000-0000-000000000001",
"name" : "master.key",
"type" : "API_KEY"
}
EOF
=> status: 201 CREATED a91c0001-0000-0000-0000-000000000001
{
"uuid" : "a91c0001-0000-0000-0000-000000000001",
"name" : "master.key",
"organization" : "master",
"type" : "API_KEY",
"apiKey" : "hsak_master.key.a339232888fde1e12507a315b4addaf9a5603c07f0f851cfc7d6add9e73954bb",
"scopes" : null,
"expiresAt" : null
}
The grant API needs the UUID of the role which we want to grant.
HTTP GET "/api/rbac/roles?name=rbac.global%23global%3AADMIN" \
-H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
`# {` \
`# "sub" : "uuid<hsh-alex_superuser>"` \
`# }`
=> status: 200 OK
[ {
"uuid" : "16e992d4-bed6-4678-9c76-8ee498fb13db",
"object.uuid" : "d906a1a8-bf20-4c1e-8251-8101f1d69af2",
"objectTable" : "rbac.global",
"objectIdName" : "global",
"roleType" : "ADMIN",
"roleName" : "rbac.global#d906a1a8-bf20-4c1e-8251-8101f1d69af2:ADMIN",
"roleIdName" : "rbac.global#global:ADMIN"
} ]
HTTP POST "/api/rbac/grants" \
-H "Authorization: Bearer $HSADMINNG_JWT_BEARER" \
`# {` \
`# "sub" : "uuid<hsh-alex_superuser>"` \
`# }` \
-H 'Hostsharing-Assumed-Roles: rbac.global#global:ADMIN' \
<<EOF
{
"assumed" : true,
"grantedRole.uuid" : "16e992d4-bed6-4678-9c76-8ee498fb13db", // globalAdminRoleUuidToGrant
"granteeSubject.uuid" : "a91c0001-0000-0000-0000-000000000001"
}
EOF
=> status: 201 CREATED 16e992d4-bed6-4678-9c76-8ee498fb13db // globalAdminRoleUuidToGrant
HTTP GET "/api/hs/accounts/current" \
-H "Hostsharing-Api-Key: $HSADMINNG_API_KEY"
=> status: 200 OK
{
"subject" : {
"uuid" : "a91c0001-0000-0000-0000-000000000001",
"name" : "master.key",
"organization" : "master",
"type" : "API_KEY"
},
"person" : null,
"globalAdmin" : true
}
generated on 2026-08-10 04:42:37 for branch HEAD